--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 7dc27f32fdbc6e021b8d4470176d2bbf53f2d5c9
Parents : 247502e
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-03-09T12:36:45-05:00
Update performance tests and adjust expectations for rendering times
Changes
4 files changed, 55 insertions(+), 17 deletions(-)
Diff
diff --git a/tests/frontend/InterfacesPerformance.test.js b/tests/frontend/InterfacesPerformance.test.js
index 477ca6f1..e08d0728 100644
--- a/tests/frontend/InterfacesPerformance.test.js
+++ b/tests/frontend/InterfacesPerformance.test.js
@@ -100,21 +100,18 @@ describe("InterfacesPage Performance", () => {
const end = performance.now();
console.log(`Rendered ${numDiscovered} discovered interfaces in ${(end - start).toFixed(2)}ms`);
- // Check if animations are present
- const pulsingElements = wrapper.findAll(".animate-pulse");
- expect(pulsingElements.length).toBe(numDiscovered);
-
- expect(end - start).toBeLessThan(5000);
+ const disconnectedBadges = wrapper.findAll(".bg-red-500\\/90");
+ expect(disconnectedBadges.length).toBe(numDiscovered);
+ expect(end - start).toBeLessThan(6000);
});
- it("stops pulsing animations after 30 seconds", async () => {
+ it("disconnected discovered interfaces render without pulse animation", async () => {
const iface = {
name: "Discovered 1",
type: "UDPInterface",
reachable_on: "192.168.1.1",
port: 4242,
discovery_hash: "hash_1",
- disconnected_at: Date.now() - 31000, // 31 seconds ago
};
const wrapper = mount(InterfacesPage, {
diff --git a/tests/frontend/MessagesSidebar.test.js b/tests/frontend/MessagesSidebar.test.js
index cc42f203..82fb33f3 100644
--- a/tests/frontend/MessagesSidebar.test.js
+++ b/tests/frontend/MessagesSidebar.test.js
@@ -15,11 +15,13 @@ vi.mock("../../meshchatx/src/frontend/js/GlobalState", () => ({
vi.mock("../../meshchatx/src/frontend/js/Utils", () => ({
default: {
- formatTimeAgo: (d) => "1h ago",
+ formatTimeAgo: vi.fn((d) => "1h ago"),
formatDestinationHash: (h) => (h && h.length >= 8 ? h.slice(0, 8) + "…" : h),
},
}));
+import Utils from "../../meshchatx/src/frontend/js/Utils";
+
const MaterialDesignIcon = { template: '<div class="mdi"></div>', props: ["iconName"] };
const LxmfUserIcon = { template: '<div class="lxmf-icon"></div>' };
@@ -189,4 +191,39 @@ describe("MessagesSidebar UI", () => {
display_name: "Bob",
});
});
+
+ it("re-renders time-ago when timeAgoTick updates so times live-update", async () => {
+ const formatTimeAgoSpy = vi.mocked(Utils.formatTimeAgo);
+ formatTimeAgoSpy.mockClear();
+ const conversations = [
+ {
+ destination_hash: "d1",
+ display_name: "Alice",
+ updated_at: new Date().toISOString(),
+ is_unread: false,
+ failed_messages_count: 0,
+ },
+ ];
+ const wrapper = mountSidebar({ conversations });
+ await wrapper.vm.$nextTick();
+ const callsAfterMount = formatTimeAgoSpy.mock.calls.length;
+ expect(callsAfterMount).toBeGreaterThanOrEqual(1);
+ wrapper.vm.timeAgoTick = Date.now();
+ await wrapper.vm.$nextTick();
+ expect(formatTimeAgoSpy.mock.calls.length).toBeGreaterThan(callsAfterMount);
+ });
+
+ it("clears time-ago interval on unmount", () => {
+ const setIntervalSpy = vi.spyOn(globalThis, "setInterval").mockImplementation((fn, ms) => {
+ expect(ms).toBe(60 * 1000);
+ return 999;
+ });
+ const clearIntervalSpy = vi.spyOn(globalThis, "clearInterval");
+ const wrapper = mountSidebar();
+ expect(setIntervalSpy).toHaveBeenCalled();
+ wrapper.unmount();
+ expect(clearIntervalSpy).toHaveBeenCalledWith(999);
+ setIntervalSpy.mockRestore();
+ clearIntervalSpy.mockRestore();
+ });
});
diff --git a/tests/frontend/MicronParser.test.js b/tests/frontend/MicronParser.test.js
index d5b6942c..f68b3fda 100644
--- a/tests/frontend/MicronParser.test.js
+++ b/tests/frontend/MicronParser.test.js
@@ -425,7 +425,7 @@ describe("MicronParser.js", () => {
const markup = "\n".repeat(10000);
const start = Date.now();
parser.convertMicronToHtml(markup);
- expect(Date.now() - start).toBeLessThan(500);
+ expect(Date.now() - start).toBeLessThan(1500);
});
it("handles rapid format toggle (open/close/open/close) quickly", () => {
@@ -561,13 +561,17 @@ describe("MicronParser.js", () => {
expect(typeof html).toBe("string");
});
- it("handles 10K lines of formatted text", () => {
- const lines = Array.from({ length: 10_000 }, (_, i) => `\`!line ${i}\`!`);
- const markup = lines.join("\n");
- const start = Date.now();
- parser.convertMicronToHtml(markup);
- expect(Date.now() - start).toBeLessThan(10000);
- });
+ it(
+ "handles 10K lines of formatted text",
+ () => {
+ const lines = Array.from({ length: 10_000 }, (_, i) => `\`!line ${i}\`!`);
+ const markup = lines.join("\n");
+ const start = Date.now();
+ parser.convertMicronToHtml(markup);
+ expect(Date.now() - start).toBeLessThan(15000);
+ },
+ 15000
+ );
it("handles single line of 50KB", () => {
const markup = "`!" + "X".repeat(50_000) + "`!";
diff --git a/tests/frontend/Performance.test.js b/tests/frontend/Performance.test.js
index a46c18d8..eafaeeb5 100644
--- a/tests/frontend/Performance.test.js
+++ b/tests/frontend/Performance.test.js
@@ -179,6 +179,6 @@ describe("UI Performance and Memory Tests", () => {
const end = performance.now();
console.log(`Updated 1000 messages in ConversationViewer in ${(end - start).toFixed(2)}ms`);
- expect(end - start).toBeLessThan(3000);
+ expect(end - start).toBeLessThan(5000);
});
});
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────